<?php
/**
 * Created by PhpStorm.
 * User: alice
 * Date: 2015/12/28
 * Time: 12:26
 */

/**
 * Class Involved_SupplyModel
 */
class Involved_SupplyModel extends BaseModel{

    protected $table = 'supply';


    /**
     * 获取供货单
     * @param $is_self
     * @param $user_id
     * @return mixed
     * @author alice
     * @date 2016-2-16
     */
    public function GetSupplyList($is_self,$page,$user_id)
    {
        $where = [];
        if($is_self == 1){
            $where['supplier_id'] = $user_id;
        }

        $offset = ($page-1) * HostEnum::PAGE_NUM;

        return  DB::table($this->table)
            ->select('supply_id','contact','mobile','spec','stock','storage','price','created','product_name','supplier_id')
            ->where($where)
            ->skip($offset)->take(HostEnum::PAGE_NUM)
            ->get();

    }


    public function SupplyList()
    {
        return  DB::table($this->table)->get();
    }













}